﻿using Domain.Sys;
using IServices;
using IServices.Sys;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Web;

namespace Web.Framework
{
    public interface IUserRole
    {
        bool Check(UserInfo userInfo, string pageurl);
    }

    public class UserRole : IUserRole
    {
       
        private readonly IRoleService _rService;

        public UserRole(IRoleService rService)
        {
            _rService = rService;
        }

        public bool Check(UserInfo userInfo, string pageurl)
        {
            if (userInfo.IsAdmin == 1)
            {
                return true;
            }
            else
            {
                return _rService.CheckRoleControllerAction(userInfo.UserId, pageurl);
            }
        }
    }
}